package com.mobiusws.reports.dao;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import com.mobiusws.reports.model.Operators;
import com.mobiusws.util.OperatorConstants;
import com.mobiusws.util.SqlUtil;

@Repository("initOperatorDao")
public class InitOperatorDao {
	@Resource
	private SqlUtil sqlUtil;
	@Resource
	private JdbcTemplate coreJdbc;
	
	public void init() {
		String sql= sqlUtil.getSqlById("getOperators");
		List<Operators> list=coreJdbc.query(sql, new Object[]{}, new BeanPropertyRowMapper(Operators.class));
		Operators oper=list.get(0);
		OperatorConstants.MCC=oper.getMcc();
		OperatorConstants.MNC=oper.getMnc();
		OperatorConstants.COUNTRY_CODE=oper.getCountryCode();
		OperatorConstants.OPERATOR_NAME=oper.getOperatorName();
		OperatorConstants.TBLNAME=oper.getTblname();
		OperatorConstants.TIMEZONE=oper.getTimezone();
		OperatorConstants.MASK_VALUE=oper.getMaskValue();
		//testInit();
	}
	
	private void testInit() {
		System.out.printf("%s, %s, %s, %s, %s, %s, %d", OperatorConstants.MCC, OperatorConstants.MNC, OperatorConstants.COUNTRY_CODE, OperatorConstants.OPERATOR_NAME, OperatorConstants.TBLNAME, OperatorConstants.TIMEZONE, OperatorConstants.MASK_VALUE);
		System.out.println();
	}
}
